package com.dream.inspect.modules.job.task;



import com.dream.inspect.modules.app.controller.AppSuperviseProjectController;
import com.dream.inspect.modules.business.dao.SuperviseStandardDao;
import com.dream.inspect.modules.business.entity.SuperviseProjectEntity;
import com.dream.inspect.modules.business.service.SuperviseProjectService;
import com.dream.inspect.modules.business.service.SysMessageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;


@Component("rejectProjectTask")
public class RejectProjectTask{
	private Logger logger = LoggerFactory.getLogger(getClass());

	@Autowired
	SuperviseProjectService superviseProjectService;
	@Autowired
	AppSuperviseProjectController appSuperviseProjectController;


	public void rejectProject(String params){
		Map<String, String> param = new HashMap<String, String>();
		param.put("id",params);
		SuperviseProjectEntity s = superviseProjectService.findSuperviseProjectForCzztById(param);
		if(s != null){
			String czzt = s.getCzzt();
			//操作状态为1 考虑到有先取消在申请立项 故对截止时间进行判断
			if("1".equals(czzt) && s.getJzrq().getTime() <= (new Date()).getTime()){
				logger.info("开始自动驳回立项");
				param.put("lxspzt","1");
				param.put("bhlxyy","立项到截止时间未审批自动驳回");
				param.put("userId","1");//系统管理员
				param.put("userDeptId",(s.getZbdwId()+""));
				param.put("userName","系统管理员");
				param.put("czzt","4");
	//			param.put("roleId","4");
				appSuperviseProjectController.updateSuperviseProject(param);
				logger.info("自动驳回立项完成");
			}
		}

	}
	

}
